const int TrigPin = 11;
const int EchoPin = 12;
float distance;


void setup() {
  Serial.begin(9600);
  pinMode(TrigPin, OUTPUT);
  pinMode(EchoPin, INPUT);
  Serial.println("Ultrasonic sensor:");
}


void loop() {
  digitalWrite(TrigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(TrigPin, HIGH);
  delayMicroseconds(100);
  digitalWrite(TrigPin, LOW);
  distance = pulseIn(EchoPin, HIGH) / (1000 / 340 * 2);
  Serial.print("distance: ");
  Serial.print(distance);
  Serial.print("cm");
  Serial.println();
  delay(500);
}
